package demo3;

public class Test {
    public static void change(Test test1,Test test2) {
        int tmp=test1.a;
        test1.a= test2.a;;
        test2.a=tmp;
    }
    public int a;
    public static void main(String[] args) {
        Test test1=new Test();
        test1.a=10;
        Test test2=new Test();
        test2.a=5;
        System.out.println("交换前: a1="+test1.a+" a2="+test2.a);
        change(test1,test2);
        System.out.println("交换后: a1="+test1.a+" a2="+test2.a);
    }
}
